Kinetis SDK Demo Applications User Guide  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fsl_mma8451.h File Reference
#include "i2c_master/fsl_i2c_master_driver.h"

Go to the source code of this file.

Data Structures

struct  mma8451_device_t
 MMA8451 driver instance. More...
 
struct  acceleration_t
 3D acceleration values. More...
 

Enumerations

enum  _mma8451_constants {
  kMMA8451_STATUS,
  kMMA8451_OUT_X_MSB,
  kMMA8451_OUT_X_LSB,
  kMMA8451_OUT_Y_MSB,
  kMMA8451_OUT_Y_LSB,
  kMMA8451_OUT_Z_MSB,
  kMMA8451_OUT_Z_LSB,
  kMMA8451_F_SETUP,
  kMMA8451_TRIG_CFG,
  kMMA8451_SYSMOD,
  kMMA8451_INT_SOURCE,
  kMMA8451_WHO_AM_I,
  kMMA8451_WHO_AM_I_Device_ID,
  kMMA8451_XYZ_DATA_CFG,
  kMMA8451_CTRL_REG1,
  kMMA8451_CTRL_REG2,
  kMMA8451_CTRL_REG3,
  kMMA8451_CTRL_REG4,
  kMMA8451_CTRL_REG5
}
 Register definitions for the MMA8451. More...
 

Functions

int32_t mma8451_init (mma8451_device_t *device, uint8_t i2c_addr, uint32_t baud_kbps)
 Initialize the MMA8451 driver instance. More...
 
int32_t mma8451_get_acceleration (const mma8451_device_t *device, acceleration_t *accel)
 Read the current acceleration values. More...
 
uint8_t mma8451_read_register (const mma8451_device_t *device, uint8_t reg_addr)
 Read a single register of the MMA8451. More...
 
int32_t mma8451_write_register (const mma8451_device_t *device, uint8_t reg_addr, uint8_t reg_val)
 Write a single register of the MMA8451. More...
 

Data Structure Documentation

struct mma8451_device_t
Data Fields
i2c_device_t address
struct acceleration_t
Data Fields
int32_t x
int32_t y
int32_t z

Enumeration Type Documentation

Enumerator
kMMA8451_STATUS 
kMMA8451_OUT_X_MSB 
kMMA8451_OUT_X_LSB 
kMMA8451_OUT_Y_MSB 
kMMA8451_OUT_Y_LSB 
kMMA8451_OUT_Z_MSB 
kMMA8451_OUT_Z_LSB 
kMMA8451_F_SETUP 
kMMA8451_TRIG_CFG 
kMMA8451_SYSMOD 
kMMA8451_INT_SOURCE 
kMMA8451_WHO_AM_I 
kMMA8451_WHO_AM_I_Device_ID 
kMMA8451_XYZ_DATA_CFG 
kMMA8451_CTRL_REG1 
kMMA8451_CTRL_REG2 
kMMA8451_CTRL_REG3 
kMMA8451_CTRL_REG4 
kMMA8451_CTRL_REG5 

Function Documentation

int32_t mma8451_get_acceleration ( const mma8451_device_t device,
acceleration_t accel 
)
Parameters
devicePointer to a valid device instance structure.
accelPointer to a structure that will be filled in with the current acceleration values for all three axes.
Returns
kStatus_Success or error code.
Return values
kStatus_Success
int32_t mma8451_init ( mma8451_device_t device,
uint8_t  i2c_addr,
uint32_t  baud_kbps 
)
Parameters
deviceDevice driver state structure that will be filled in by this function. It is the responsibility of the caller to provide storage for this structure, and to free that storage when the driver is no longer needed.
isSaoSet
baud_kbps
Returns
kStatus_Success or error code.
Return values
kStatus_Success
kMMA8451_Invalid_I2C_Address_Error
uint8_t mma8451_read_register ( const mma8451_device_t device,
uint8_t  reg_addr 
)
Parameters
devicePointer to a valid device instance structure.
reg_addrAddress of the internal MMA8451 register to read.
Returns
The register's value.
int32_t mma8451_write_register ( const mma8451_device_t device,
uint8_t  reg_addr,
uint8_t  reg_val 
)
Parameters
devicePointer to a valid device instance structure.
reg_addrAddressof the internal MMA8451 register to change the value of.
reg_valNew value for the register.
Returns
kStatus_Success or error code.
Return values
kStatus_Success